package normal.栈;

import java.util.Stack;

/**
 * java自带的栈数据结构
 *
 * @author ZhuYi
 * @create 2024/12/16 10:22
 */
public class JavaStack {
    public static void main(String[] args) {
        Stack<Integer> stack = new Stack<>();
        stack.push(1);//入栈
        stack.push(2);
        stack.push(3);
        stack.push(4);
        stack.push(5);

        int peek = stack.peek();//访问栈顶元素
        int pop = stack.pop();//出栈
        int size = stack.size();//栈的长度
        boolean empty = stack.empty();//栈是否为空

        System.out.println(peek + " " + pop + " " + size + " " + empty);
    }
}
